<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>

</body>
<script src="./js/ajax.js"></script>
<script>
// async function fn() {
//     var msg1 = await new Promise(function(resolve, reject) {
//         sendAjax({
//             url: 'http://localhost:3000/user',
//             success: function(msg1) {
//                 resolve(msg1)
//             }
//         })
//     })
//     console.log(msg1);
//     console.log(666);
// }

// var a = fn()


// await会等待异步执行结束，再向下执行
async function fn() {
    var num = await new Promise(function(resolve, reject) {
        setTimeout(function() {
            resolve(666)
        }, 5000)
    })
    console.log(num);
    console.log(7777);
}

fn()
</script>
</html>